package cz.data.domain.security.rpc;

import cz.data.common.annotation.DataInner;
import cz.data.common.base.BaseResponse;
import cz.data.common.base.SimpleDataResponse;
import cz.data.common.core.AuthUser;
import cz.data.common.core.DataConstant;
import cz.data.common.core.DataUser;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;

@FeignClient(contextId = "OAuth2ServiceFeign", value = "data-auth")
public interface OAuth2ServiceFeign {

    @GetMapping("/oauth/userinfo")
    SimpleDataResponse<DataUser> userinfo(@RequestHeader(HttpHeaders.AUTHORIZATION) String tokenValue);

    @DataInner
    @GetMapping("/oauth/authorize/userinfo")
    SimpleDataResponse<AuthUser> authorizeUserinfo(@RequestHeader(HttpHeaders.AUTHORIZATION) String tokenValue);

    @GetMapping("/oauth/nacos")
    String nacosService(@RequestHeader(DataConstant.Token.SERVICE_HEADER) String authorization);

    @GetMapping("/oauth/logout")
    BaseResponse logout(@RequestHeader(DataConstant.Token.TOKEN_JTI_HEADER) String jti,
                        @RequestHeader(HttpHeaders.AUTHORIZATION) String tokenValue);

    @GetMapping("/oauth/jwks")
    String jwkSource();
}
